public class PinPass {

	private String tarjetaCodigo[][] = {
			{ " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J" },
			{ "1", "21", "80", "88", "98", "77", "66", "44", "55", "33", "22" },
			{ "2", "32", "18", "16", "15", "97", "76", "65", "45", "56", "34" },
			{ "3", "10", "26", "21", "43", "59", "91", "62", "42", "17", "12" },
			{ "4", "99", "11", "31", "73", "40", "50", "89", "61", "37", "42" },
			{ "5", "98", "19", "41", "23", "30", "20", "92", "86", "35", "27" } };

	public String[] generarCoordenadas() {
		int x0 = (int) ((Math.random() * 10) + 1);
		int y0 = (int) ((Math.random() * 4) + 1);
		int x1 = (int) ((Math.random() * 10) + 1);
		int y1 = (int) ((Math.random() * 4) + 1);
		int x2 = (int) ((Math.random() * 10) + 1);
		int y2 = (int) ((Math.random() * 4) + 1);

		String coor1 = (tarjetaCodigo[0][x0] + "" + tarjetaCodigo[y0][0]);
		String coor2 = (tarjetaCodigo[0][x1] + "" + tarjetaCodigo[y1][0]);
		String coor3 = (tarjetaCodigo[0][x2] + "" + tarjetaCodigo[y2][0]);

		String[] coordenadas = { coor1, coor2, coor3 };

		return coordenadas;

	}

	public int validar(String coor1Ingresada, String coor2Ingresada,
			String coor3Ingresada, String[] coord) {

		int nCoor1[] = busca(coord[0].toString());
		int nCoor2[] = busca(coord[1].toString());
		int nCoor3[] = busca(coord[2].toString());

		boolean correcto1 = false;
		boolean correcto2 = false;
		boolean correcto3 = false;

		if (tarjetaCodigo[nCoor1[1]][nCoor1[0]].equals(coor1Ingresada)) {
			correcto1 = true;
		}
		if (tarjetaCodigo[nCoor2[1]][nCoor2[0]].equals(coor2Ingresada)) {
			correcto2 = true;
		}
		if (tarjetaCodigo[nCoor3[1]][nCoor3[0]].equals(coor3Ingresada)) {
			correcto3 = true;
		}

		if ((correcto1 && correcto2) && correcto3) {
			System.out.println("PIN PASS CORRECTO");
			return 0;
		} else {
			System.out.println("PIN PASS INCORRECTO");
			return 1;

		}
	}

	public int[] busca(String llegada) {

		String letra = "" + llegada.charAt(0);
		String nume = "" + llegada.charAt(1);
		int num_int = 0;
		int letra_int = 0;
		for (int i = 1; i < 11; i++) {

			if (tarjetaCodigo[0][i].equalsIgnoreCase(letra)) {

				letra_int = i;
			}
		}
		for (int j = 1; j < 5; j++) {

			if (tarjetaCodigo[j][0].equals(nume)) {
				num_int = j;
			}
		}

		int[] valoresCoordenadas = { letra_int, num_int };

		return valoresCoordenadas;
	}

	// public void imprime(){
	// for(int i=0;i<tarjetaCodigo.length;i++){
	// for(int j=0;j<tarjetaCodigo[0].length;j++){
	// System.out.print(" "+ tarjetaCodigo[i][j]);
	// }
	// System.out.println();
	// }

	// }

}
